<!--  -->
<template>
  <header>
    <div class="l-container">
      <el-button type="primary"   icon="el-icon-menu" size="mini" @click="collapseMenu" ></el-button>
      <el-breadcrumb separator="/" class="topBoard">
        <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
        <el-breadcrumb-item :to="current.path" v-if="current">
          {{current.label}}
        </el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <div class="r-container">
      <el-dropdown trigger="click">
        <span class="el-dropdown-link">
          <img :src="userImg" alt="">
        </span>
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item icon="el-icon-plus">个人中心</el-dropdown-item>
          <el-dropdown-item icon="el-icon-circle-plus" @click.native="logOut">退出</el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
    </div>
  </header>
</template>

<script>
import { mapState } from 'vuex'
export default {
  computed: {
    ...mapState({
      current: state => state.tab.currentMenu
    })
  },
  data() {
    return {
      userImg: require('../assets/image/user.png')
    }
  },
    methods:{
      collapseMenu(){
        this.$store.commit('CollapseMenu')
      },
      logOut(){
        this.$store.commit('clearToken')
        this.$store.commit('clearMenu')
        location.reload() //加上这一句，当点击退出的时候，会将刷新页面（将当前页面清空）
      }
    }
}
</script>

<style lang="scss" scoped>
header {
  display: flex;
  height: 100%;
  align-items: center; // align-items 盒子中的元素纵向排列
  justify-content: space-between; //justify-content 盒子中的元素横向排列
  .l-container {
    display: flex;
    height: 100%;
    align-items: center;
    .topBoard {
      margin-left: 40px;
    }
  }
  .r-container {
    img {
      width: 40px;
      height: 40px;
      border-radius: 50%;
    }
  }
}
</style>
<style lang="scss">
.el-breadcrumb__item {
  .el-breadcrumb__inner{
    color: #666666;
    font-weight: normal;
  }
  &:last-child {
    .el-breadcrumb__inner {
      color: #fff;
    }
  }
}
</style>